﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using DAL;

namespace BLL
{
     public  class RegardBLL
    {
         //实例化用户与文章
         RegardDAL rdal = new RegardDAL();
        /// <summary>
        /// 获取用户收藏的文章
        /// </summary>
        /// <param name="Login_Id"></param>
        /// <returns></returns>
         public PageList<RegardModel> GetRegard(int Login_Id, int PageIndex, int PageSize)
        {
            PageList<RegardModel> Page = new PageList<RegardModel>();
            Page.PageIndex = PageIndex;
            Page.PageSize = PageSize;
            Page.PageCount = (int)Math.Ceiling((double)rdal.CCount(Login_Id) / PageSize);
            Page.Data = rdal.GetRegard(Login_Id, PageIndex, PageSize);
            return Page;
        }
        /// <summary>
        /// 获取用户收藏的文章详细信息
        /// </summary>
        /// <param name="Login_Id"></param>
        /// <returns></returns>
        public RegardModel GetRegardId(int Login_Id, int Id)
        {
            return rdal.GetRegardId(Login_Id,Id);
        }
        ///// <summary>
        ///// 获取文章
        ///// </summary>
        ///// <param name="Login_Id"></param>
        ///// <returns></returns>
        //public List<RegardModel> GetRegardALL()
        //{
        //    return rdal.GetRegardALL();
        //}
        /// <summary>
        /// 分页显示文章
        /// </summary>
        /// <returns></returns>
        public PageList<RegardModel> GetRegardALL(int PageIndex, int PageSize)
        {
            PageList<RegardModel> Page = new PageList<RegardModel>();
            Page.PageIndex = PageIndex;
            Page.PageSize = PageSize;
            Page.PageCount = (int)Math.Ceiling((double)rdal.Count() / PageSize);
            Page.Data = rdal.GetRegardALL(PageIndex, PageSize);
            return Page;
        }
        /// <summary>
        /// 获取文章详细信息
        /// </summary>
        /// <param name="Login_Id"></param>
        /// <returns></returns>
        public RegardModel GetRegardIdAll(int Id)
        {
            return rdal.GetRegardIdAll(Id);
        }
        /// <summary>
        /// 判断文章是否已经收藏
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public int AddRegard(int Login_Id,int Id)
        {
            return rdal.AddRegard(Login_Id,Id);
        }
        /// <summary>
        /// 收藏
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public int AddRegardDo(int Login_Id, int Id)
        {
             return rdal.AddRegardDo(Login_Id,Id);
        }
        /// <summary>
        /// 收藏文章伪删除
        /// </summary>
        /// <param name="Login_Id"></param>
        /// <param name="Id"></param>
        /// <returns></returns>
        public int Del(int Login_Id, int Id)
        {
            return rdal.Del(Login_Id,Id);
        }
    }
}
